// H5环境兼容性修复
// 解决 chunk-vendors.js postMessage 错误

// 修复 self.postMessage 问题
if (typeof self !== 'undefined' && typeof self.postMessage === 'undefined') {
    self.postMessage = function(message, targetOrigin, transfer) {
        // 空实现，防止报错
        console.log('H5 Fix: postMessage called with:', message);
    };
}

// 修复 window.self 问题
if (typeof window !== 'undefined') {
    if (!window.self) {
        window.self = window;
    }
    if (!window.self.postMessage) {
        window.self.postMessage = function(message, targetOrigin, transfer) {
            console.log('H5 Fix: window.self.postMessage called with:', message);
        };
    }
}

// 修复可能的 Worker 相关问题
if (typeof global !== 'undefined' && !global.postMessage) {
    global.postMessage = function(message) {
        console.log('H5 Fix: global.postMessage called with:', message);
    };
}

export default {
    init() {
        console.log('H5 compatibility fixes applied');
    }
};